package logic

import (
	"context"
	"merchantmanager/models/mysql"

	"merchantmanager/merchantmanagerrpc/internal/svc"
	"merchantmanager/merchantmanagerrpc/merchantmanagerrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MerchantmanagerAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMerchantmanagerAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MerchantmanagerAddLogic {
	return &MerchantmanagerAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 添加
func (l *MerchantmanagerAddLogic) MerchantmanagerAdd(in *merchantmanagerrpc.MerchantmanagerAddRequest) (*merchantmanagerrpc.MerchantmanagerAddResponse, error) {
	// todo: add your logic here and delete this line

	merchants := mysql.Merchants{
		Name:  in.Name,
		Types: in.Types,
		Time:  in.Time,
	}

	mysql.DB.Debug().Create(&merchants)

	return &merchantmanagerrpc.MerchantmanagerAddResponse{
		Id: int64(merchants.ID),
	}, nil
}
